package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("SELECT count(1)  from t_order where  MEMBER_ID=#{mid} and SETMEAL_ID=#{sid} and ORDERDATE=#{orderDate} ")
    int findOrderByMemberIdAndSetmealIdAndOrderDate(@Param("mid") Integer mid,@Param("sid") int sid, String orderDate);

    @Select("SELECT tmr.`NAME` as member,tsl.`NAME` as setmeal, tor.ORDERDATE as orderDate " +
            ", tor.ORDERTYPE as orderType from t_order tor, t_member tmr, " +
            "t_setmeal tsl where tor.MEMBER_ID=tmr.ID and tor.SETMEAL_ID=tsl.ID " +
            "and tor.ID=#{oid} ")
    Map findOrderInfoById(@Param("oid") Integer oid);
}
